package cz.fit.vutbr.pis2012.augeaswh.control.whman.slots;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.richfaces.component.SortOrder;

@ManagedBean
@SessionScoped
public class SlotsSortingBean implements Serializable {
	private static final long serialVersionUID = -1210517902807488690L;
	private SortOrder nameOrder = SortOrder.ascending;
    private SortOrder sectorOrder = SortOrder.unsorted;
    private SortOrder capacityOrder = SortOrder.unsorted;
        
    public void sortByName() {
        sectorOrder = SortOrder.unsorted;
        capacityOrder = SortOrder.unsorted;
        
        if (nameOrder.equals(SortOrder.ascending)) {
            setNameOrder(SortOrder.descending);
        } else {
        	setNameOrder(SortOrder.ascending);
        }
    }
    
    public void sortBySector() {
        nameOrder = SortOrder.unsorted;
        capacityOrder = SortOrder.unsorted;
                
        if (sectorOrder.equals(SortOrder.ascending)) {
            setSectorOrder(SortOrder.descending);
        } else {
        	setSectorOrder(SortOrder.ascending);
        }
    }
    
    public void sortByCapacity() {
        nameOrder = SortOrder.unsorted;
        sectorOrder = SortOrder.unsorted;
                
        if (capacityOrder.equals(SortOrder.ascending)) {
            setCapacityOrder(SortOrder.descending);
        } else {
        	setCapacityOrder(SortOrder.ascending);
        }
    }
    
	public SortOrder getNameOrder() {
		return nameOrder;
	}

	public void setNameOrder(SortOrder nameOrder) {
		this.nameOrder = nameOrder;
	}

	public SortOrder getSectorOrder() {
		return sectorOrder;
	}

	public void setSectorOrder(SortOrder productClassOrder) {
		this.sectorOrder = productClassOrder;
	}

	public SortOrder getCapacityOrder() {
		return capacityOrder;
	}

	public void setCapacityOrder(SortOrder priceOrder) {
		this.capacityOrder = priceOrder;
	}
}
